package com.zxj.shop.back.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zxj.shop.common.controller.BaseController;
import com.zxj.shop.common.util.ConstatfinalUtil;
import com.zxj.shop.common.util.PageInfoUtil;
import com.zxj.shop.goods.pojo.AGoodsBrand;
import com.zxj.shop.goods.service.IGoodsService;

@Controller
@RequestMapping("/back/goods")
public class GoodsBackController extends BaseController
{
	@Resource
	private IGoodsService goodsService;
	
	/*--------品牌操作开始-------*/
	/**
	 * 品牌列表
	 */
	@RequestMapping("/brandList")
	public String brandList(HttpServletRequest request)
	{
		ConstatfinalUtil.LOGGER.info("--brandList-----");
		/*接受搜索条件*/
		String keyword=request.getParameter("keyword");
		String status=request.getParameter("status");
		String st=request.getParameter("st");
		String ed=request.getParameter("ed");
		/*处理搜索条件*/
		if(keyword==null)
		{
			keyword="";
		}
		keyword=keyword.trim();
		if(status==null)
		{
			status="";
		}
		if(st==null)
		{
			st="";
		}
		if(ed==null)
		{
			ed="";
		}
		Date stDate=null;
		Date edDate=null;
		if(!"".equalsIgnoreCase(st)&&!"".equalsIgnoreCase(ed))
		{
			stDate=this.dateFormatUtil.parse(st);
			edDate=this.dateFormatUtil.parse(ed);
		}
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		if(!"".equalsIgnoreCase(status))
		{
			condMap.put("status", status);
		}
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		/*分页*/
		PageInfoUtil paInfoUtil=this.proccedPageInfo(request);
		List<AGoodsBrand> goodsBrandList=this.goodsService.findCondListGoodsBrandService(paInfoUtil, condMap);
		/* 存储结果 */
		request.setAttribute("goodsBrandList", goodsBrandList);
		request.setAttribute("pageInfoUtil", paInfoUtil);
		
		/* 存储条件 */
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		return "/back/goods/brandList";
	}
	/*------品牌操作结束---------*/

}
